<?php

class Antz_Email
{

    public static function sendRaw($subject, $content, $toFrom, $html=true){
        if(!$html) $content = strip_tags($content);

        // from 5th august 2008 we use the CMSms mailer
        $Antz = Antz::registry('Antz');

        if( $cmsmailer =& $Antz->GetModuleInstance('CMSMailer') ){
            $cmsmailer->ClearAddresses();
            if(isset($toFrom['fromName']) && isset($toFrom['fromEmail'])){
            	$cmsmailer->SetFrom($toFrom['fromEmail']);
                $cmsmailer->SetFromName($toFrom['fromName']);
            };
      	    $cmsmailer->AddAddress( $toFrom['toEmail'], $toFrom['toName'] );
      	    $cmsmailer->SetSubject( $subject );
      	    $cmsmailer->IsHTML( $html );

      	    $cmsmailer->SetBody( $content );
      	    return $cmsmailer->Send();

        }else{
            global $gCms;
            include_once($gCms->config['root_path'].'/modules/Antz/ThirdParty/phpmailer/class.phpmailer.php');

            $mail = new PHPMailer;
            $mail->IsMail();
            $mail->From = $toFrom['fromEmail'];
            $mail->FromName = $toFrom['fromName'];
            $mail->AddAddress($toFrom['toEmail'], $toFrom['toName']);
            $mail->WordWrap = 50;
            $mail->IsHTML($html);
            $mail->Subject = $subject;
            $mail->Body = $content;
            $mail->AltBody = strip_tags($content);

            return $mail->Send();

        };
    }



}
